package com.itheima.d1_char_stream;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 目标：掌握文件字符输入流。
 */
public class FileReaderTest1 {
    public static void main(String[] args) {

     /* try( FileReader fr = new FileReader("day10io-app2/file1")){;
       int c;
       while((c = fr.read())!=-1) {
           System.out.println((char) (c));
       }
       }catch (Exception e){
          e.printStackTrace();
      }*/

        try( FileReader fr = new FileReader("day10io-app2/file1")){
            char [] chars = new char[1024];
            int len;
            while((len = fr.read(chars))!=-1) {
                String s = new String(chars, 0, len);
                System.out.println(s);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
